import request from 'utils/request'

// 定义分类
const fetchCates = (params = {}) => request.get('/shop/goods/category/all', { params })

// 首页轮播
const fetchBanner = (params = {}) => request.get('/banner/list', { params })
// 商品列表
const fetchItems = (params = {}) => request.post('/shop/goods/list/v2', params)
// 商品详情
const fetchDetail = (id) => request.get('/shop/goods/detail', {
  params: {
    id
  }
})
// 注册用户名
const register = (params = {}) => request.post('/user/username/register', params)
// 用户登录
const fetchLogin = (params = {}) => request.post('/user/username/login', params)
// 加入购物车
const addCart = (params = {}) => request.post('/shopping-cart/add', params)
// 读取购物车数据
const readCart = (params = {}) => request.get('/shopping-cart/info', { params })
// 修改购物车购买数据
const fetchCartNum = (params = {}) => request.post('/shopping-cart/modifyNumber', params)
// 移除购物车数据
const delCartNum = (params = {}) => request.post('/shopping-cart/remove', params)
// 修改商品的选中状态
const changeItemSelect = (params = {}) => request.post('/shopping-cart/select', params)
// 添加收获地址
const addContact = (params = {}) => request.post('/user/shipping-address/add', params)
// 联系人列表
const fetchContactLists = (params = {}) => request.post('/user/shipping-address/list/v2', params)
// 修改联系人信息
const fetchContactUpdate = (params = {}) => request.post('/user/shipping-address/update', params)
// 收货人地址详情
const fetchContactDetail = (params = {}) => request.get('/user/shipping-address/detail/v2', { params })
// 删除联系人
const deleteContact = (params = {}) => request.post('/user/shipping-address/delete', params)
// 获取联系人默认收货地址， （修改联系人，点击把信息添加在修改页上）
const fetchContactDefault = (params = {}) => request.get('/user/shipping-address/default/v2', { params })

export {
  fetchCates,
  fetchBanner,
  fetchItems,
  fetchDetail,
  register,
  fetchLogin,
  addCart,
  readCart,
  fetchCartNum,
  delCartNum,
  changeItemSelect,
  addContact,
  fetchContactLists,
  fetchContactUpdate,
  fetchContactDetail,
  deleteContact,
  fetchContactDefault
}
